package com.quiz.bis.mapper;

import com.quiz.bis.domain.model.ExamSubgroupMember;
import com.quiz.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 分组-成员关联Mapper接口
 */
@Mapper
public interface ExamSubgroupMemberMapper extends BaseMapperPlus<ExamSubgroupMember> {
    @Select("SELECT * FROM exam_subgroup_members WHERE subgroup_id = #{subgroupId} AND del_flag = 0")
    List<ExamSubgroupMember> selectBySubgroupId(@Param("subgroupId") Long subgroupId);

    @Select("SELECT user_id FROM exam_subgroup_members WHERE subgroup_id = #{subgroupId} AND del_flag = 0")
    List<Long> selectUserIdsBySubgroupId(@Param("subgroupId") Long subgroupId);

    List<Long> selectJoinExamStudentIdList(@Param("subgroupIds") List<Long> subgroupIds, @Param("excludedUserIds") List<Long> excludedUserIds);

    @Delete("DELETE FROM exam_subgroup_members WHERE subgroup_id = #{subgroupId} AND user_id IN (${userIds})")
    int deleteMembers(@Param("subgroupId") Long subgroupId, @Param("userIds") String userIds);


}
